<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<%@ page contentType="text/html; charset=utf-8"%>
	<%@ include file="/commons/taglibs.jsp"%>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		<title>应用服务管理</title>

		<%@ include file="/commons/css_js_head.jsp"%>
		<script type="text/javascript">
//复写Url
doListUrl = "${ctx }/base/appServerAction!doList.ts";
doAddBeforeUrl = "${ctx }/base/appServerAction!doFindById.ts";
doUpdateBeforeUrl = "${ctx }/base/appServerAction!doFindById.ts";
doDelUrl = "${ctx }/base/appServerAction!doDelete.ts"
//添加之前
function doAddBefore() {
	var _form = document.forms[0];
	if (doAddBeforeUrl == '') {
		alert('请设置正确的URL!');
		return false;
	}

	_form.action = doAddBeforeUrl;
	_form.submit();
}

//更新之前 
function doUpdateBefore(pkId) {
	//var _form = document.forms[0];
	//if (doUpdateBeforeUrl == '') {
	//	alert('请设置正确的URL!');
	//	return false;
	//}

	//_form.action = doUpdateBeforeUrl + "?asId=" + pkId;
	//_form.submit();
	
	tb_show("update","${ctx }/base/appServerAction!doFindById.ts?asId=" + pkId+"&keepThis=true&TB_iframe=true&width=800&height=400&modal=true",false);
}

//删除
function doDel(pkId) {
	var _form = document.forms[0];
	if (doDelUrl == '') {
		alert('请设置正确的URL!');
		return false;
	}
	if(confirm("确定下线?"))
		{
		
			$.ajax({
      type : "post",
      url : "${ctx }/base/appServerAction!checkIsOffLine.ts",
      cache: false,
      data : "&asId="+pkId,
      success : function(data){
      
      if( data != "0" )
       {
          alert("下线前，请先取消终端！");
          
           return false;
        }
       else
       {
            _form.action = doDelUrl + "?asId=" + pkId;
	       _form.submit();
			return true;
       }
      },
     error: function(){
     	  
           return false;
     	}
   });
		
		   
		}
		return false;
	
}
</script>
<script type="text/javascript">
function onCancel()
{
	closeWindow();
}

function closeWindow()
{
	self.parent.tb_remove();
}


function doAdd1(pkId){
  
  tb_show("add","${ctx}/base/machinesApplyAction!doAppList.ts?asId=" + pkId+"&keepThis=true&TB_iframe=true&width=600&height=400&modal=true",false);
  //this.blur();
}

 //批量选择
 function checkAll(check,me){   
    // 首先获得所有checkbox集合  
    var names = document.getElementsByName(check); 
    
    var status=me.checked; 
    
    for(var i=0;i<names.length;i++){   
        if(status==true){           
		   names[i].checked=true;}
		else{
		    names[i].checked=false;
		}   
    }   
}  
</script>

	</head>
	<body style="overflow-x: hidden">

		<!-- 标题 -->
		<div class="mTitle">
			<span class="hidsearch"><a href="javascript:void(0)"
				onClick="return chg('searchList');" id="ImgArrow"> <img
						src="${ctx}/images/icon_up.gif" id="imgButton" />
			</a> </span>
			<b class="bbig">应用平台管理</b>
			<a href="javascript:void(0)" onclick="javascript:doAddBefore();" >增加应用平台</a>
		</div>

		<!--list -->
		<div class="searchBar" id="searchList" style="display: block;">
			<form action="${ctx}/base/appServerAction!doFindByCompCode.ts" method="post">
				<table class="searchTable">
					<tr>
						<th>
							应用平台名称：
						</th>
						<td>
							<s:textfield name="name" theme="simple"></s:textfield>
						</td>
						
						
						<th>
						是否上线：
						</th>
						<td>
						<s:select list="#{1:'是',0:'否'}" 
							theme="simple"
                            name="status" 
						    cssStyle="width:50px;"
							listKey="key" 
							listValue="value"  
							headerKey="0" 
							/> 
						</td>
						
						<td>
							<input name="btn_query" type="button" class="btn" value="查询"
								onclick="doQuery()" />
							
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div class="mainList">

			<table class="listTable">
				<tr>
					<th>序号</th>
					<th>
						应用平台名称
					</th>
					<th>
						接口类型
					</th>
					<th>
						接口地址
					</th>
					<th>
						接口参数
					</th>
					<th>
						是否上线
					</th>
					<th>
						地址
					</th>
					<th>
						备注
					</th>
					<th>
						操作
					</th>
				</tr>

				<c:forEach var="appServer" varStatus="status" items="${pager.data}">
					<tr align=center>
						<td>${status.index+1} </td>
						<td>
						
							${appServer.name}
						</td>
						<td>
						<c:if test="${appServer.interType == '0'}">  <span>Socket</span> </c:if>
						 <c:if test="${appServer.interType == '1'}">  <span>Webservice</span> </c:if>
						 <c:if test="${appServer.interType == '2'}">  <span>Http</span> </c:if>
						</td>
						<td>
							${appServer.interAddress }
						</td>
						<td>
							${appServer.interMethod }
						</td>
						
						<td>
						 <c:if test="${appServer.status == '1'}">  <span>是</span> </c:if>
						 <c:if test="${appServer.status == '0'}">  <span>否</span> </c:if>
						</td>
						<td>
							${appServer.address}
						</td>
						<td>
						${appServer.remark}
						</td>
						
						<td>
									<a href="javascript:void(0)"
										onclick="javascript:doUpdateBefore('${appServer.asid}');"><span
										class="icon_edit">&nbsp;</span>修改</a>
								<c:if test="${appServer.status =='1'}">
									<a href="javascript:void(0)" onclick="javascript:doDel('${appServer.asid}');"><span
										class="icon_del">&nbsp;</span>下线</a>
								</c:if>
									<a href="javascript:void(0)" onclick="javascript:doAdd1('${appServer.asid}')"><span
										class="icon_add">&nbsp;</span>信息终端查询</a>
						</td>
					</tr>
				</c:forEach>
			</table>
		</div>
		<!--end list -->

		<!-- 分页区域  -->
<%@ include file="/page/pager.jsp"%>

<script type="text/javascript">
ajaxAnywhere.formName = "form1";
ajaxAnywhere.getZonesToReload = function() {
    return "zoneList";
}
</script>

	</body>
</html>
